request({
    type: 'get',
    url: '/admin/user/detail',
    success: function (res) {
        if (res.code == 200) {
            // 用户名
            $('#username').val(res.data.username);
            // 昵称
            $('#nickname').val(res.data.nickname);
            // 邮箱
            $('#email').val(res.data.email);
            // 密码
            $('#password').val(res.data.password);
            // 头像
            $('.user_pic').attr('src', res.data.userPic);
          }
    }
})

$('#exampleInputFile').change(() => {
    const file = $('#exampleInputFile')[0].files[0]
    const url = URL.createObjectURL(file)
    console.log(url)
    $('.user_pic').attr('src', url);
})

$('.btn-edit').on('click', (e) => {
    e.preventDefault()
    const form = $('#form')[0]
    const formData = new FormData(form)
    request({
        type: 'post',
        url: '/admin/user/edit',
        data:formData,
        success: function (res) {
            if(res.code === 200){
                alert(res.msg)
            }
        }
    })
})